package camel.corp.universalcopy;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.widget.RemoteViews;
import android.widget.Toast;
import com.camel.corp.universalcopy.SwitchAppWidgetProvider;
import com.crashlytics.android.Crashlytics;

public class SwitchAppWidgetProvider extends AppWidgetProvider {
  public static void a(Context paramContext) {
    Intent intent = new Intent(paramContext, SwitchAppWidgetProvider.class);
    intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
    intent.putExtra("appWidgetIds", AppWidgetManager.getInstance(paramContext).getAppWidgetIds(new ComponentName(paramContext, SwitchAppWidgetProvider.class)));
    paramContext.sendBroadcast(intent);
  }
  
  public void onReceive(Context paramContext, Intent paramIntent) {
    super.onReceive(paramContext, paramIntent);
    if ("universalcopy.ACTION_TOGGLE_WIDGET".equals(paramIntent.getAction())) {
      SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(paramContext);
      boolean bool1 = sharedPreferences.getBoolean("accessibility_active", false);
      boolean bool2 = sharedPreferences.getBoolean("service_active", false);
      if (bool1) {
        String str;
        sharedPreferences.edit().putBoolean("service_active", bool2 ^ true).commit();
        a(paramContext);
        if (!bool2) {
          str = "UNIVERSAL_COPY_ACTIVATE";
        } else {
          str = "UNIVERSAL_COPY_DISABLE";
        } 
        paramContext.sendBroadcast(new Intent(str));
        return;
      } 
      intent = new Intent("android.settings.ACCESSIBILITY_SETTINGS");
      intent.setFlags(268435456);
      try {
        paramContext.startActivity(intent);
        Toast.makeText(paramContext, paramContext.getText(2131755217), 1).show();
        return;
      } catch (ActivityNotFoundException intent) {
        Toast.makeText(paramContext, paramContext.getText(2131755089), 0).show();
        Crashlytics.a(intent);
      } 
    } 
  }
  
  public void onUpdate(Context paramContext, AppWidgetManager paramAppWidgetManager, int[] paramArrayOfInt) {
    super.onUpdate(paramContext, paramAppWidgetManager, paramArrayOfInt);
    int i = paramArrayOfInt.length;
    byte b;
    for (b = 0; b < i; b++) {
      int j;
      int k = paramArrayOfInt[b];
      RemoteViews remoteViews = new RemoteViews(paramContext.getPackageName(), 2131492892);
      boolean bool = PreferenceManager.getDefaultSharedPreferences(paramContext).getBoolean("service_active", false);
      if (bool) {
        j = 2131230873;
      } else {
        j = 2131230872;
      } 
      remoteViews.setImageViewResource(2131296400, j);
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("Universal Copy ");
      if (bool) {
        j = 2131755041;
      } else {
        j = 2131755079;
      } 
      stringBuilder.append(paramContext.getText(j));
      remoteViews.setContentDescription(2131296400, stringBuilder.toString());
      Intent intent = new Intent(paramContext, SwitchAppWidgetProvider.class);
      intent.setAction("universalcopy.ACTION_TOGGLE_WIDGET");
      remoteViews.setOnClickPendingIntent(2131296400, PendingIntent.getBroadcast(paramContext, 0, intent, 0));
      paramAppWidgetManager.updateAppWidget(k, remoteViews);
    } 
  }
}


/* Location:              D:\Users\alienware\AndroidStudioProjects\Lazero\sample\sampler\classes-dex2jar\com\camel.jar!\camel\cor\\universalcopy\SwitchAppWidgetProvider.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.0.7
 */